package com.itheima.exception;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;

/**
 * Demo class
 *
 * @author zy9524
 * @date 2016/10/31
 */

@ControllerAdvice
public class MyException {

    @ExceptionHandler(Exception.class)
    public ModelAndView handle(Exception e){
        ModelAndView mv = new ModelAndView();
        mv.addObject("errorMsg", e.getMessage());
        mv.setViewName("error");
        return mv;
    }
}
